import{d as k,l as B,C as q,o as t,b as m,w as p,r as C,f as i,ak as F,q as n,ax as S,F as v,t as o,m as u,c as s,H as T,p as y,aE as V}from"./index-c80Lh_is.js";const h=["data-testid"],E={key:1},w=k({__name:"DeleteResourceModal",props:{actionButtonText:{type:String,required:!1,default:"Yes, delete"},confirmationText:{type:String,required:!1,default:""},deleteFunction:{type:Function,required:!0},isVisible:{type:Boolean,required:!0},title:{type:String,required:!1,default:"Delete"}},emits:["cancel","delete"],setup(_,{emit:x}){const{t:c}=B(),a=_,d=x,e=q(null);async function b(){e.value=null;try{await a.deleteFunction(),d("delete")}catch(r){r instanceof Error?e.value=r:console.error(r)}}return(r,f)=>(t(),m(n(V),{"action-button-text":a.actionButtonText,"confirmation-text":a.confirmationText,visible:a.isVisible,title:a.title,type:"danger",onCancel:f[0]||(f[0]=l=>d("cancel")),onProceed:b},{default:p(()=>[C(r.$slots,"default"),i(),e.value!==null?(t(),m(n(F),{key:0,class:"mt-4",appearance:"danger","is-dismissible":""},{alertMessage:p(()=>[e.value instanceof n(S)?(t(),s(v,{key:0},[u("p",null,o(n(c)("common.error_state.api_error",{status:e.value.status,title:e.value.detail})),1),i(),e.value.invalidParameters.length>0?(t(),s("ul",{key:0,"data-testid":`error-${e.value.status}`},[(t(!0),s(v,null,T(e.value.invalidParameters,(l,g)=>(t(),s("li",{key:g},[u("b",null,[u("code",null,o(l.field),1)]),i(": "+o(l.reason),1)]))),128))],8,h)):y("",!0)],64)):(t(),s("p",E,o(n(c)("common.error_state.default_error")),1))]),_:1})):y("",!0)]),_:3},8,["action-button-text","confirmation-text","visible","title"]))}});export{w as _};
